<?php
// 连接到数据库

$dbc = mysqli_connect('localhost','root','root','stock');

// 设计连接器的编码方式

mysqli_set_charset($dbc, 'utf8');

// 增加数据
$sql = "INSERT INTO `user` (id, email, password, regdate)
     VALUES (NULL,'g','g',CURRENT_TIMESTAMP)";
//INSERT INTO `stock`.`user` (`id`, `email`, `password`, `regdate`) VALUES ('5', 'GG', 'HSG', CURRENT_TIMESTAMP);
$result = mysqli_query($dbc,$sql);

// 执行SQL 指令
$sql = 'SELECT *FROM `USER`';
$result = mysqli_query($dbc, $sql);

//获取查询结果
echo "<table border=1>";
while ($row = mysqli_fetch_array($result)) {
    echo "<tr><td>" . $row['id'] ."</td><td>" . $row['email'] 
         ."</td><td>" . $row['password'] ."</td><td>" . $row[
         'regdate'] ."</td></tr>";
}
echo "</table>";


// 释放资源
mysqli_free_result($result);
mysqli_close($dbc);